package com.yl.order.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.yl.common.utils.LogUtil;

import org.greenrobot.greendao.database.Database;

/**
 * create by cjx on 2024/4/21
 * desc:
 */
public class DaoOpenHelper extends DaoMaster.OpenHelper {
    public DaoOpenHelper(Context context, String path, String name) {
        super(new DatabaseContext(context, path), name, null);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        LogUtil.getInstance().log("DaoOpenHelper", "onUpgrade old:" + oldVersion + " newversion:" + newVersion);
        MigrationHelper.migrate(db,
                CategoryEntityDao.class,
                GoodsEntityDao.class,
                OrderEntityDao.class,
                OrderGoodsEntityDao.class,
                ProductEntityDao.class,
                SpecEntityDao.class
        );
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        super.onUpgrade(db, oldVersion, newVersion);
        LogUtil.getInstance().log("DaoOpenHelper2", "onUpgrade old:" + oldVersion + " newversion:" + newVersion);

    }
}
